package cn.jtool.dig.client.configuration;

import cn.jtool.dig.client.comm.tunnel.TunnelChannelInitializer;
import cn.jtool.dig.common.netty.TcpClient;
import jakarta.annotation.Resource;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 隧道配置
 */
@Data
@Slf4j
@Configuration
public class TunnelConfigure {

    @Resource
    private TunnelProperties tunnelProperties;
    @Resource
    private TunnelChannelInitializer tunnelChannelInitializer;


    @Bean("tunnelClient")
    public TcpClient tunnelClient(){
        TcpClient client = new TcpClient(0, this.tunnelProperties.getServerIp(), this.tunnelProperties.getServerPort(), Integer.MAX_VALUE, this.tunnelChannelInitializer);
        client.start();
        return client;
    }
}
